package com.wc.算法提高课.D第四章_高级数据结构.树状数组.楼兰图腾;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/5/16 22:00
 * @description https://www.acwing.com/problem/content/243/
 */
public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 200010;
    static int[] tr = new int[N];
    static long[] high = new long[N], lower = new long[N];
    static int[] w = new int[N];
    static int n;

    public static void main(String[] args) {
        n = sc.nextInt();
        for (int i = 1; i <= n; i++) w[i] = sc.nextInt();
        for (int i = 1; i <= n; i++) {
            int x = w[i];
            high[i] = sum(n) - sum(x);
            lower[i] = sum(x - 1);
            add(x, 1);
        }
        for (int i = 1; i <= n; i++) tr[i] = 0;
        long res1 = 0, res2 = 0;
        // build right
        for (int i = n; i >= 1; i--) {
            int x = w[i];
            res1 += high[i] * (sum(n) - sum(x));
            res2 += lower[i] * sum(x - 1);
            add(x, 1);
        }
        out.println(res1 + " " + res2);
        out.flush();
    }

    static void add(int x, int c) {
        for (int i = x; i <= n; i += lowbit(i)) {
            tr[i] += c;
        }
    }

    static long sum(int x) {
        long res = 0;
        for (int i = x; i > 0; i -= lowbit(i)) {
            res += tr[i];
        }
        return res;
    }

    static int lowbit(int x) {
        return x & -x;
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}